package com.ymatou.iapi.coupon.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;
/**
*幂等键是否领取了优惠券Call
*FreeMaker Template自动生成代码
*/
public class isReceivedCouponByIdempotentKeyCall extends YmatouBaseCall{
	private static String opurl ="/api/Promotion/isReceivedCouponByIdempotentKey";
	
	public isReceivedCouponByIdempotentKeyCall() {
		super(EnvSetup.getSystemUrl("couponiapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	
	/**
	 * 获取errorCode
	 * 
	 * @return
	 */
	public String getErrorCode() {
		String Code = null;
		try {
			Code =new JSONObject(getReturnData()).getJSONObject("data").getString("errorCode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}
	
	/**
	 * 获取ErrorMessag
	 * 
	 * @return
	 */
	public String getErrorMessage() {
		String Code = null;
		try {
			Code =new JSONObject(getReturnData()).getJSONObject("data").getString("errorMessage");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}
	
	/**
	 * 获取received
	 * 
	 * @return
	 */
	public boolean getReceived() {
		boolean Code = false;
		try {
			Code =new JSONObject(getReturnData()).getJSONObject("data").getBoolean("received");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}
}